import * as XLSX from "xlsx";
import { s2ab, exportOfBlob } from "@/util/index";
onmessage = e => {
  const { num, excelKeyToName } = e.data
  console.log('拿到了数据', num);
  const jsonData = []
  for (let i = 0; i < num; i++) {
    jsonData.push({
      name: `张三${i+1}`,
      age: 1 + i,
      skill: `干饭${i}`,
      telephone: 2020083 + i,
      address: `宇宙尽头${i}`,
    })
  }
  const wbout = exportOfBlob({ jsonData, excelKeyToName })

  console.log('wbout', wbout);
  self.postMessage({
    type: 'success',
    data: {
      xlsxBlob: new Blob([s2ab(wbout)], {
        // type: 'application/octet-stream'
        type: ''
      }),
    }
  });
}
